<?php
if (!defined('ABSPATH')) {
	define('ABSPATH', dirname(dirname(__FILE__)) . '/');
}

require_once ABSPATH . 'dr-config.php';
require_once ABSPATH . DRINC . '/dr-base.php';
require_once ABSPATH . DRINC . '/dr-functions.php';

require_once ABSPATH . DRINC . '/dr-smarty.php';
require_once ABSPATH . DRINC . '/dr-themes.php';

require_once ABSPATH . DRINC . '/dr-page-check-login.php';

$user_id = dr_is_login_on();

$order = dr_get('order');
$rank      = isset($_GET['rank']) ? dr_get('rank') : "";

$orders = array('number', 'name');
if (!in_array($order, $orders))
	$order = 'name';

if (!in_array($rank, array('d4', 'w4', 'm4', 'a4')))
	$rank = '';

$posts = array(
	'action' => 'get_all_tags',
	'order' => $order,
	'rank' => $rank,
	'user_id' => $user_id,
	'match_str' => ''
);

// 获取数据库中问题相关的数据
$result = dr_server_request('dr-app-tags.php', $posts);

$result_array = json_decode($result, 1);

//将数据转换成html格式后输出
dr_to_html($result_array['tags']);

//var_dump($result_array);

$smarty->assign('page_title', '标签 - ' . get_site_name());

$smarty->assign('tags', $result_array['tags']);
$smarty->assign('topNum', $result_array['topNum']);
$smarty->assign('rank', $rank);
$smarty->assign('setting', $result_array['setting']);

$content = array();
$content['top_navs'] = get_page_top_navigation();
$content['menus'] = get_page_menus('tags');
$content['tabs'] = get_page_tabs('tags-old', $order);

$smarty->assign('content', $content);

$smarty->display('tags.tpl');


